﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// user_adv
	/// </summary>
	public partial class user_adv
	{
		private readonly lcmyjobs.DAL.user_adv dal=new lcmyjobs.DAL.user_adv();
		public user_adv()
		{}
		#region  Method
        public DataSet PageUserAdvHunter(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserAdvHunter(atid, startid, pagesize, out count);
        }

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int aid)
		{
			return dal.Exists(aid);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.user_adv model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.user_adv model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int aid)
		{
			
			return dal.Delete(aid);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string aidlist )
		{
			return dal.DeleteList(aidlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.user_adv GetModel(int aid)
		{
			
			return dal.GetModel(aid);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.user_adv GetModelByCache(int aid)
		{
			
			string CacheKey = "user_advModel-" + aid;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(aid);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.user_adv)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.user_adv> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.user_adv> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.user_adv> modelList = new List<lcmyjobs.Model.user_adv>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.user_adv model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.user_adv();
					if(dt.Rows[n]["aid"]!=null && dt.Rows[n]["aid"].ToString()!="")
					{
						model.aid=int.Parse(dt.Rows[n]["aid"].ToString());
					}
					if(dt.Rows[n]["abh"]!=null && dt.Rows[n]["abh"].ToString()!="")
					{
					model.abh=dt.Rows[n]["abh"].ToString();
					}
					if(dt.Rows[n]["uid"]!=null && dt.Rows[n]["uid"].ToString()!="")
					{
						model.uid=int.Parse(dt.Rows[n]["uid"].ToString());
					}
					if(dt.Rows[n]["yearpay"]!=null && dt.Rows[n]["yearpay"].ToString()!="")
					{
						model.yearpay=int.Parse(dt.Rows[n]["yearpay"].ToString());
					}
					if(dt.Rows[n]["advstatus"]!=null && dt.Rows[n]["advstatus"].ToString()!="")
					{
						model.advstatus=int.Parse(dt.Rows[n]["advstatus"].ToString());
					}
					if(dt.Rows[n]["advtime"]!=null && dt.Rows[n]["advtime"].ToString()!="")
					{
						model.advtime=DateTime.Parse(dt.Rows[n]["advtime"].ToString());
					}
					if(dt.Rows[n]["OKstatus"]!=null && dt.Rows[n]["OKstatus"].ToString()!="")
					{
						if((dt.Rows[n]["OKstatus"].ToString()=="1")||(dt.Rows[n]["OKstatus"].ToString().ToLower()=="true"))
						{
						model.OKstatus=true;
						}
						else
						{
							model.OKstatus=false;
						}
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

